{extend name="app/base" /}

{block name="body"}

{include file="app/components/header" /}

{if condition="$addonInfo.entry_url neq ''"}
<div >
    <table class="layui-table" lay-skin="line">
        <colgroup>
            <col width="150">
            <col width="">
            <col>
        </colgroup>
        <thead>
        <tr>
            <th>二维码</th>
            <th>入口链接</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>
                <img src="/system/index/getQrCode?text={$entryUrl}" width="100" height="100">
            </td>
            <td>
                <p style="font-size: 18px;">
                    <a class="apiUrl" href="javascript:;">{$entryUrl}</a>
                    <span class="tip1 bt-a"></span>
                </p>
                <p style="color: #787878;">(直接指向到入口的URL。您可以在自定义菜单（有oAuth权限）或是其它位置直接使用。)</p>
            </td>
            <td><button id="apiUrl" class="layui-btn layui-btn-xs">复制链接</button></td>
        </tr>

        </tbody>
    </table>
</div>
{/if}

{if $isShowApi==true}
<form class="layui-form" action="" style="padding-right: 10px;">
    <div class="layui-tab">
        <ul class="layui-tab-title" >
            <li {eq name="type" value="addon" }class="layui-this" {/eq}><a href="{:url('index',['name'=>$addonInfo.addon, 'type'=>'addon'])}">响应应用</a></li>
        </ul>

        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <br>
                {eq name="type" value="addon" }
                <div class="layui-form-item">
                    <label class="layui-form-label">关键词</label>
                    <div class="layui-input-block">
                        <input type="text" name="keyword"  value="{$rule.keyword}"  placeholder="请输入关键词" class="layui-input">
                        <p style="font-size: 12px; padding: 7px;color: #787878;">此关键词响应此应用。(不是开发者不用理解此：响应addons/{$addonInfo.addon}/controller下的Api.php)</p>
                    </div>
                </div>
                {/eq}

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="hidden" id="__token__" name="__token__" value="{:request()->token()}" />
                        <input hidden name="name" value="{$addonInfo.addon}" />
                        <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </div>

        </div>
    </div>

</form>
{/if}
{/block}

{block name="js"}
<script src="__STATIC__/libs/zclip/jquery.zclip.min.js"></script>
<script>
    layui.use(['form'], function(){
        var form = layui.form
                ,layer = layui.layer;

        form.on('submit(demo1)', function(data){
            let loading_index = layer.load(1);
            $.post('', data.field, function (res) {
                layer.close(loading_index);
                if(res.code === 1){
                    layer.msg(res.msg, {time:1000}, function () {});
                }else{
                    $('#__token__').val(res.data.token);
                    layer.alert(res.msg);
                }
            });
            return false;
        });
    });

    $(function () {
        $('#apiUrl').zclip({
            path: '__STATIC__/libs/zclip/ZeroClipboard.swf',
            copy: function(){
                $(".tip1").show();
                return $('.apiUrl').text();
            },
            afterCopy: function(){
                $(".tip1").insertAfter($('.tip1')).html('复制成功').fadeOut(2000);
            }
        });
    })
</script>
{/block}